package com.liu.lab10.service.impl;

import com.liu.lab10.service.UserService;
import com.liu.lab10.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

@Service("userServiceImpl")
public class UserServiceImpl implements UserService {
	// 声明UserDao属性
	@Autowired
	@Qualifier("userDaoImpl")
	private UserDao userDao;
	// 添加UserDao属性的setter方法，用于实现依赖注入
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}


//	有参构造
	public UserServiceImpl( UserDao userDao ) {
		this.userDao = userDao;
	}

	// 无参数构造方法
	public UserServiceImpl(  ) {

	}
	// 实现的接口中方法
	@Override
	public void info(int id,String name) {
		System.out.println("userService info is called!");
		//info()方法，并执行输出语句
		this.userDao.info(id,name);
	}
	@Override
	public boolean login(String name, String password) {
		System.out.println("userService login is called!");
		return userDao.login(name,password);
	}
}
